package com.bwie.gddproject.index.adapter;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bwie.gddproject.R;
import com.bwie.gddproject.classify2.view.AclassActivity;
import com.bwie.gddproject.index.model.bean.Classify2Bean;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

/**
 * Created by 我走路带风 on 2017/12/17.
 */

class RightBottom_Adapter extends RecyclerView.Adapter{
    private Context context;
    private List<Classify2Bean.DataBean.ListBean> list;
    public RightBottom_Adapter(Context context, List<Classify2Bean.DataBean.ListBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context,R.layout.classify_right_bottom_item,null);

        return new MyHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MyHolder myHolder = (MyHolder) holder;
        Classify2Bean.DataBean.ListBean listBean = list.get(position);
        myHolder.right_bottom_sim.setImageURI(Uri.parse(listBean.getIcon()));
        myHolder.right_bottom_tv.setText(listBean.getName());
        myHolder.right_bottom_ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(context, AclassActivity.class);
                intent.putExtra("pscid",85+"");
                context.startActivity(intent);
            }
        });
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    class MyHolder extends RecyclerView.ViewHolder{
        LinearLayout right_bottom_ll;
        SimpleDraweeView right_bottom_sim;
        TextView right_bottom_tv;

        public MyHolder(View itemView) {
            super(itemView);
            right_bottom_ll = itemView.findViewById(R.id.right_bottom_ll);
            right_bottom_sim = itemView.findViewById(R.id.right_bottom_sim);
            right_bottom_tv = itemView.findViewById(R.id.right_bottom_tv);
        }
    }
}
